const userController = require('../controller/user.controller')
const { commonValidator,encryptPassword } = require('../middleware/global.middleware')
const KoaRouter = require('@koa/router')
const Joi = require('joi')
// 创建路由
const userRouter = new KoaRouter({ prefix: '/user' })
// 创建用户
userRouter.post('/register', commonValidator({
  name: Joi.string().required(),
  password: Joi.string().pattern(new RegExp('^(?:(?=.*[a-zA-Z])(?=.*\d)|(?=.*[a-zA-Z])(?=.*[!@#$%^&*()\-_=+{};:,<.>])|(?=.*\d)(?=.*[!@#$%^&*()\-_=+{};:,<.>])).{8,}$')).required()
}),encryptPassword,userController.create)

module.exports = userRouter